/**
 * bootstrap datatimepicker plugins
 */
(function() {
	'use strick',
	require.config({
		paths: {
			"bootstrap.datetimepicker": "bootstrap/extends/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min"
		},
		shim: {
			"bootstrap.datetimepicker": {
				deps : [
				   "moment", 
				   "jquery", 
				   "css!bootstrap/extends/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css"
				],
				exports:"jQuery.fn.datetimepicker"
			}
		}
	});
	
	define(['bootstrap.datetimepicker'], function(){
		return {
			register:function(elem, options, others){
				var _opts = $.extend({
					dayViewHeaderFormat: "YYYY MMMM",
					widgetPositioning: { vertical: 'auto' },
					allowInputToggle: true,
					showTodayButton: true,
					defaultDate: new Date(),
					showClear: true,
					locale: "zh-CN",
					format: "YYYY-MM-DD"
				}, options);
		  
				if(!jQuery(elem).data("DateTimePicker")){
					jQuery(elem).datetimepicker(_opts);
				}
				
				if(others) {
					var datepicker = jQuery(elem).data("DateTimePicker");
					jQuery.each(others,function(method, value){
						datepicker[method](value);
					});
				}
			}
		}
	});
})(this);
